package com.cloudfun.campusshare.common.model.dto;

import com.cloudfun.campusshare.common.constant.DeviceType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

/**
 * @author wangxiyuan
 * @description
 * @createDate 2021/5/20 13:46
 **/
@Data
@ApiModel(value = "补货列表")
@Accessors(chain = true)
public class ReplenishDTO {
    private String washPointId;
    private String concretePositionId;

    @ApiModelProperty(value = "栋")
    private String building;

    @ApiModelProperty(value = "层")
    private String floor;

    @ApiModelProperty(value = "室")
    private String room;

    @ApiModelProperty(value = "设备名称")
    private String deviceName;

    @ApiModelProperty(value = "设备类型")
    private String deviceType;

    @ApiModelProperty(value = "归属运营商")
    private String belongMerchantName;

    @ApiModelProperty(value = "场地名称")
    private String washPointName;

    @ApiModelProperty(value = "设备识别码")
    private String imei;

    @ApiModelProperty(value = "设备状态,true表示在线，false离线")
    private boolean online;

    @Getter(AccessLevel.NONE)
    private String onlineStr;

    @ApiModelProperty(value = "补货状态 1:充足 2:报警 3:待补货")
    private Integer replenishStatus;

    @ApiModelProperty(value = "洗衣液库存情况")
    private Integer laundryDetergent;

    @ApiModelProperty(value = "消毒液库存情况")
    private Integer disinfectant;

    @ApiModelProperty(value = "洗衣液默认容量")
    private Integer lDefaultSize;

    @ApiModelProperty(value = "消毒液默认容量")
    private Integer dDefaultSize;

    @ApiModelProperty(value = "洗衣液操作按钮")
    private boolean laundryOperation;

    @ApiModelProperty(value = "消毒液操作按钮")
    private boolean disinfectantOperation;

    public String getOnlineStr() {
        return online == true ? "在线" : "离线";
    }

    /**
     *
     * @param lThreshold 洗衣液阈值
     * @param dThreshold 消毒液阈值
     */
    public void checkOperation(int lThreshold,int dThreshold){
        if(this.replenishStatus != 1){
            if(laundryDetergent <= lThreshold){
                this.laundryOperation = true;
            }
            if(disinfectant <= dThreshold && StringUtils.equals(deviceType, DeviceType.PUMP_LA_2.name())){
                this.disinfectantOperation = true;
            }
        }
    }
}
